﻿<%@ Page Language="C#" MasterPageFile="../shared/blog.master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage, System.Web.Mvc" ValidateRequest="false" %>


<asp:Content ID="BlogWriteHead" ContentPlaceHolderID="BlogHead" runat="server" EnableViewState="false">
<%
    string skinpath = ViewData["skinpath"] as string;
    if (skinpath == null)
    {
        throw new ArgumentNullException("ViewData[\"skinpath\"]");
    }
%>
<script type="text/javascript" src="<%=Url.Content("~/fckeditor/fckeditor.js") %>"></script>
<script type="text/javascript" src="<%=Url.Content("~/" + skinpath + "js/common.js") %>"></script>
<script type="text/javascript">
//<!--
function CheckPost(){
    var contentEditor=FCKeditorAPI.GetInstance('content');
    var introEditor=FCKeditorAPI.GetInstance('intro');
    var checkMessage=document.getElementById("checkmessage");
    var title=document.getElementById("title");
    var come=document.getElementById("come");
    var comeurl=document.getElementById("comeurl");
    var postbutton=document.getElementById("postbutton");
    var returnbutton=document.getElementById("returnbutton");
    var result=true;
    var message="";
    var num=1;
    returnbutton.disabled="disabled";
    postbutton.disabled="disabled";
    if(title.value.length<1){
        result=false;
        message += num.toString() + ".标题不能为空.<br />";
        num++;
    }
    if(come.value.length<1){
        result=false;
        message += num.toString() + ".文章来源不能为空.<br />";
        num++;
    }
    if(comeurl.value.length<1){
        result=false;
        message += num.toString() + ".来源Url不能为空.<br />";
        num++;
    }
    if(contentEditor.GetXHTML(true).length<1){
        result=false;
        message += num.toString() + ".正文不能为空.<br />";
        num++;
    }
    if(introEditor.GetXHTML(true).length<1){
        result=false;
        message += num.toString() + ".摘要不能为空.<br />";
        num++;
    }
    if(!result){
        postbutton.disabled="";
        returnbutton.disabled="";
        checkMessage.style.display="";
        checkMessage.innerHTML="无法提交数据,请参考以下信息:<br />" + message;
    }
    return result;
}
//-->
</script>
</asp:Content>

<asp:Content ID="BlogWriteContent" ContentPlaceHolderID="BlogContent" runat="server" EnableViewState="false">
<%
    string skinpath = ViewData["skinpath"] as string;
    IList<lb_category> categoryList = ViewData["postcategories"] as IList<lb_category>;
    lb_config config = ViewData["config"] as lb_config;
    if (skinpath == null)
    {
        throw new ArgumentNullException("ViewData[\"skinpath\"]");
    }
    if (categoryList == null)
    {
        throw new ArgumentNullException("ViewData[\"categories\"]");
    }
    if (config == null)
    {
        throw new ArgumentNullException("ViewData[\"postcategories\"]");
    }
%>
<div style="text-align:center;">
  <br/>
  <script type="text/javascript">
  //<!--
    var fckPath='<%=Url.Content("~/fckeditor/") %>';
    //添加上传链接
	function AddFiles(fID, extName, fileUrl){
		var regex=/jpg|jpeg|gif|png|bmp/;
		var data="";
		if(regex.test(extName)){
			//alert("是图片");
			data+="<br /><img src=\"" + fileUrl + "\" alt=\"\" border=\"0\" /><br />";
		}else{
			//alert("不是图片");
			data+="<br /><img src=\"<%=Url.Content("~/" + skinpath + "images/download.gif") %>\" alt=\"下载文件\" style=\"margin:0px 2px -4px 0px\"/><a href=\"" + fileUrl + "\" title=\"点击下载此文件\" target=\"_blank\">点击下载此文件</a><br />";
		}		
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		// Check the active editing mode.
		if ( oEditor.EditMode != FCK_EDITMODE_WYSIWYG ){
			// Insert the desired HTML.
			//oEditor.EditMode = FCK_EDITMODE_WYSIWYG;
			oEditor.Commands.GetCommand( "Source" ).Execute()
		}
		oEditor.InsertHtml( data ) ;
	}
  //-->
  </script>
  
   <!--内容-->
  
  <!--第二步-->
    <form name="frm" action="<%=Url.Action("post") %>" method="post" onsubmit="return CheckPost();">
  	<div id="MsgContent" style="width:700px">
        <div id="MsgHead">发表新日志</div>
        <div id="MsgBody">        
          <table width="100%" border="0" cellpadding="2" cellspacing="0">
            <tr>
            <td width="72" height="24" align="right" valign="top"><span style="font-weight: bold">分类选择:</span></td>
            <td align="left"><%=Html.DropDownList("category", new SelectList(categoryList, "id", "name"))%>
              </td>
            </tr>
            <tr>
              <td width="72" height="24" align="right" valign="top"><span style="font-weight: bold">标题:</span></td>
              <td align="left"><input name="title" type="text" class="inputBox" id="title" size="50" maxlength="255"/>
              </td>
              <td width="120" rowspan="3" align="center">
              </td>
            </tr>
            <tr>
              <td height="24" align="right" valign="top"><span style="font-weight: bold">参数:</span></td>
              <td width="517" align="left">
                <label for="label">
                <input id="istemp" name="istemp" type="checkbox" value="true" />
        保存为草稿</label>
                <label for="label2">
                <input name="islock" type="checkbox" id="islock" value="true" />
        禁止评论</label>
                <label for="label3">
                <input name="istop" type="checkbox" id="istop" value="true" />
        日志置顶</label>
              </td>
            </tr>
            <tr>
              <td height="24" align="right" valign="top">&nbsp;</td>
              <td align="left"><span style="font-weight: bold">来自:</span>
                  <input name="come" type="text" id="come" value="本站原创" size="12" class="inputBox" />
                  <span style="font-weight: bold">网址:</span>
                  <input name="comeurl" type="text" id="comeurl" value="<%=config.url %>" size="38" class="inputBox" />
                </td>
            </tr>
<%--            <tr>
              <td height="24" align="right" valign="top"><span style="font-weight: bold">发表时间:</span></td>
              <td align="left">
                  <label for="P1"><input name="posttimetype" type="radio" id="P1" value="now" size="12" checked/>当前时间</label> 
                  <label for="P2"><input name="posttimetype" type="radio" id="P2" value="com" size="12" />自定义日期:</label>
                  <input name="posttime" type="text" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" size="21" class="inputBox" /> (格式:yyyy-mm-dd hh:mm:ss)
                </td>
            </tr>--%>
            <tr>
              <td height="24" align="right" valign="top"><span style="font-weight: bold">Tags:</span></td>
              <td align="left">
                      <input name="tags" type="text" value="" size="50" class="inputBox" /> <img src="<%=Url.Content("~/" + skinpath + "images/insert.gif") %>" alt="插入已经使用的Tag" onclick="popnew('<%=Url.Action("subtags") %>','tag','250','324')" style="cursor:pointer"/> (tag之间用英文的逗号分割)
               </td>
            </tr>
             <tr>
              <td  align="right" valign="top"><span style="font-weight: bold">内容:</span></td>
              <td colspan="2" align="center">
              <div>
              <script type="text/javascript">
                var oContent = new FCKeditor( 'content','100%','350px' ) ;
				oContent.BasePath	= fckPath ;
				oContent.Value = "";
				oContent.ToolbarSet="LevenBlog";
				//oContent.EnableSourceXHTML=true;
				oContent.Create() ;
              </script>
              </div></td>
            </tr>
  
          <tr>
              <td  align="right" valign="top"><span style="font-weight: bold">内容摘要:</span></td>
              <td colspan="2" align="left">
              <div id="Div_Intro">
              <script type="text/javascript">
                var oContent = new FCKeditor( 'intro','100%','150px' ) ;
				oContent.BasePath	= fckPath ;
				oContent.Value = "";
				oContent.ToolbarSet="LevenIntro";
				//oContent.EnableSourceXHTML=true;
				oContent.Create() ;
              </script>
              </div>
              </td>
          </tr>          <tr>
              <td align="right" valign="top" nowrap><span style="font-weight: bold">附件上传:</span></td>
              <td colspan="2" align="left">
              <iframe src="<%=Url.Action("upload") %>" width="100%" height="24" frameborder="0" scrolling="no" border="0" frameborder="0"></iframe>
              </td>
            </tr>
            <tr>
              <td colspan="3" align="center">
                <input name="postbutton" id="postbutton" type="submit" class="userbutton" value="提交日志" accesskey="S"/>
                <input name="returnbutton" id="returnbutton" type="button" class="userbutton" value="返回" accesskey="Q" onClick="history.go(-1)"/></td>
            </tr>
            <tr>
               <td height="24" align="right" valign="top"></td>
              <td colspan="2" align="left">
                <div id="checkmessage" style="width:100%; border:#f37c3f 1px solid; background:#eaeaea; padding:3px 0px 3px 0px; display:none;">
                
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="3" align="right">
                友情提示:保存草稿后，日志不会在日志列表中出现。只有再次编辑，<b>取消草稿</b>后才显示出来。</td>
            </tr>
           </table>
        </div>
  	</div>
  </form>
  <br/> 
 </div>

</asp:Content>